//###############
//FILE : FileGoAwaySession.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############

package oop.ex3.protocol.sessions;

import oop.ex3.protocol.messages.GoAwayMsg;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import oop.ex3.exceptions.InvalidMessageException;

/**
 * Tell a NS to shut down.
 * @author daniel
 */
public class FileGoAwaySession extends FileToNameSession {

	/**
	 * Create a new session.
	 */
    public FileGoAwaySession() {
        super();
    }

    @Override
    protected boolean specExecuteSession(DataInputStream inputStream, DataOutputStream outputStream) throws IOException, InvalidMessageException {
        if (!initSession(inputStream, outputStream))
        	return false;

        GoAwayMsg goAway = new GoAwayMsg();
        goAway.send(outputStream);
        _done.receive(inputStream);

        if (!endSession(inputStream, outputStream))
            return false;
        
        return true;
    }

}
